package leetcode.code0523;

import java.util.HashSet;
import java.util.Set;

import leetcode.IDebug;

public class Solution implements IDebug {

	public boolean checkSubarraySum(int[] nums, int k) {
		int len = nums.length;
		Set<Integer> set = new HashSet<>();
		int sum = 0, last = 0;
		for (int i = 0; i < len; i++) {
			sum += nums[i];
			int mod = sum % k;
			if ((i > 0 && mod == 0) || (i > 1 && set.contains(mod))) {
				return true;
			}
			set.add(last);
			last = mod;
		}
		return false;
	}

	@Override
	public void debug4() {


	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
